package org.fatmansoft.teach.controllers;

import org.fatmansoft.teach.payload.request.DataRequest;
import org.fatmansoft.teach.payload.response.DataResponse;
import org.fatmansoft.teach.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/api/course")
public class CourseController {

    @Autowired
    CourseService courseService;

    @PostMapping("/getCourseList")
    public DataResponse getCourseList(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.getCourseList(dataRequest);
    }

    @PostMapping("/getCourseInfo")
    public DataResponse getCourseInfo(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.getCourseInfo(dataRequest);
    }

    @PostMapping("/saveCourse")
    public DataResponse saveCourse(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.saveCourse(dataRequest);
    }

    @PostMapping("/deleteCourse")
    public DataResponse deleteCourse(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.deleteCourse(dataRequest);
    }

    @PostMapping("/getSelectedCourseList")
    public DataResponse getSelectedCourseList(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.getSelectedCourseList(dataRequest);
    }

    @PostMapping("/getNotSelectedCourseList")
    public DataResponse getNotSelectedCourseList(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.getNotSelectedCourseList(dataRequest);
    }

    @PostMapping("/insertStudentCourse")
    public DataResponse insertStudentCourse(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.insertStudentCourse(dataRequest);
    }

    @PostMapping("/deleteStudentCourse")
    public DataResponse deleteStudentCourse(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.deleteStudentCourse(dataRequest);
    }

    @PostMapping("/getSelectedNum")
    public DataResponse getSelectedNum(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.getSelectedNum(dataRequest);
    }

    @PostMapping("/getLoginTeacherCourse")
    public DataResponse getTeacherCourse(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.getLoginTeacherCourse(dataRequest);
    }

    @PostMapping("/getStudentByCourseNum")
    public DataResponse getStudentByCourseNum(@Valid @RequestBody DataRequest dataRequest) {
        return  courseService.getStudentByCourseNum(dataRequest);
    }

    @PostMapping("/getStudentScore")
    public DataResponse getStudentScore(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.getStudentScore(dataRequest);
    }

    @PostMapping("/saveStudentScore")
    public DataResponse saveStudentScore(@Valid @RequestBody DataRequest dataRequest) {
        return courseService.saveStudentScore(dataRequest);
    }
}
